package com.gin.no_gay_alliance.adpter.user;

import android.app.Activity;
import android.content.Context;
import android.view.View;

import androidx.annotation.NonNull;

import com.gin.no_gay_alliance.R;
import com.gin.no_gay_alliance.adpter.base.BaseBindingRecyclerViewAdapter;
import com.gin.no_gay_alliance.databinding.ItemUserInfoBinding;
import com.gin.no_gay_alliance.utils.ClipboardUtils;
import com.gin.no_gay_alliance.viewmodel.KeyValue;

import java.util.List;

/**
 * 用户基础信息
 *
 * @author : ginstone
 * @version : v1.0.0
 * @since : 2023/8/11 11:19
 **/
public class UserInfoAdapter extends BaseBindingRecyclerViewAdapter<ItemUserInfoBinding, KeyValue> implements View.OnClickListener {
    public UserInfoAdapter(Context context) {
        super(context);
    }

    public UserInfoAdapter(@NonNull Context context, @NonNull List<KeyValue> data) {
        super(context, data);
    }

    @Override
    protected void onBindViewHolder(ViewHolder<ItemUserInfoBinding> holder, @NonNull ItemUserInfoBinding b, int position, KeyValue item) {
        b.tvKey.setText(item.key);
        b.tvValue.setText(String.valueOf(item.value));

        b.layoutParent.setTag(item);
        b.layoutParent.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        if (v.getId() == R.id.layout_parent) {
            KeyValue item = (KeyValue) v.getTag();
            ClipboardUtils.setText((Activity) context, item.value.toString(), "已复制:" + item.key);
        }
    }
}